package cn.eoe.example.my_texttospeech;

import android.content.Context;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {
    @BindView(R.id.button)
    Button button;
    @BindView(R.id.textView)
    EditText textView;
    private  TTSHelper ttsHelper;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
    }

    @Override
    protected void onStart() {
        super.onStart();
        //初始化
        ttsHelper=new TTSHelper(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //销毁
        ttsHelper.stopTTS();
    }
    @OnClick(R.id.button)
    public void onViewClicked() {
        //speakOut("大噶好，我是渣渣辉");
        ttsHelper.speakOut(textView.getText().toString());
        textView.setText("");
    }

}

